Release 10.1A: OpenEdge Development:
ProDataSets
Extending the sample procedures to track changes
You can track changes in a ProDataSet to extend the sample window
dsOrderWin.wand its supporting procedures:
![]()
To track changes in the ProDataSet:
- Save a new version of the window procedure
dsOrderWin.wasdsOrderWinUpd.w.- Enable the
Price,Qty, andDiscountcolumns in thettOlinebrowse.To do this, double-click on the browse, choose the Fields button in its property sheet, and double-click on each of the three fields. An ‘e’ appears next to each field to indicate that it is now enabled for input, as shown:
![]()
You have to define a before-table for the
ttOlinetemp-table. Because this is a static temp-table, its before-table must be defined statically as well.- Edit the include file
dsOrderTT.ito add theBEFORE-TABLEdefinition to the temp-table forOrderLines, as shown:
Using this definition, Progress creates the companion temp-table
ttOlineBeforealong withttOline. The two temp-tables share the same scope. You can referencettOlineBeforein your procedure code just as you canttOline, but you cannot directly make any changes to its records. The before-table remains empty until you setTRACKING-CHANGESto true forttOlineand start making changes tottOlinerecords.You need to set the
TRACKING-CHANGESattribute to enable tracking of any updates to theOrderLines.- In the
LEAVEtrigger for fieldiOrderNum, add a line to setTRACKING-CHANGEStoTRUEafter receiving anOrderProDataSet back fromOrderMain.p. In addition, setTRACKING-CHANGEStoFALSEbefore requesting the ProDataSet, as shown:
When you set
TRACKING-CHANGEStoTRUE, you enable the user to change thePrice,Qty, andDiscountfields of one or morettOlinerecords and have those changes recorded in the client window procedure. For each change, Progress adds a record tottOlineBeforewith the record’s values before it was first changed.To make sure that you can select and view one
Orderand then another without getting an error that says you are doing aFILLwhenTRACKING-CHANGESisTRUE, you need to setTRACKING-CHANGEStoFALSEbefore making the call toOrderMain.p.You need to assign changes made to the browse columns.
- Define this
ROW-LEAVEtrigger for theOlineBrowse:
In this trigger block, if the browse row has been modified, you assign the list of enabled columns. This is available as the preprocessor value
ENABLED-FIELDS-IN-QUERY-OlineBrowse, which allows you to make changes to the list of enabled columns without having to remember to go back to change a hard-coded field list in this trigger.Once the user has made any changes, you prevent them from switching
Ordersuntil the changes have been saved back to the database, by disabling theiOrderNumfield.- Progress does not automatically set the
MODIFIEDbrowse attribute toFALSEwhen you switch rows, so you need to define aVALUE-CHANGEDtrigger block for theOlineBrowse, as shown:
The
ROW-LEAVEevent fires before the browse switches rows, when you press the up or down arrow or select a different row with the mouse, for example. This lets you capture changes to the current row. TheVALUE-CHANGEDtrigger fires after the browse switches rows, so it would be too late to capture changes to the row you left. All you can do here is reset theMODIFIEDattribute in preparation for the next change.Start to build the trigger code that sends changes back to the database.
- In the AppBuilder, drop a new button called
BtnSaveonto the window and label it Save Changes.- To illustrate how
ROW-STATEand theBEFORE/AFTER-ROWIDattributes work, add this code to theCHOOSEtrigger for the button:
For each
OrderLinethat you change, there should be a record inttOlineBefore. That record points to its companion inttOlineusing theAFTER-ROWIDattribute. TheMESSAGEdisplays the value ofROW-STATEfor each record, along with thePricebefore and after the change.- To try this out, run the window procedure, select an
Order, and modify one or two of thePricevalues of itsOrderLines.- Choose the Save Changes button.
For each
OrderLineyou changed, you should see a message like the following for aPricechange from23.95to23.85:
![]()
This confirms that the
ROW-STATEattribute is always set for both the before-table record and the after-table record, so that you can query it starting at either table. TheROW-STATEvalue of2represents the literalROW-MODIFIED. In the case of a delete, of course, there will be a record with aROW-STATEof1(ROW-DELETED) only in the before-table, and no record in the after-table.The message also confirms that the before-table record holds the value of the fields before any changes were made, and the after-table holds the modified values.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |